package cn.zch.soft.util.gitalibaba.excel.read;
import cn.hutool.core.io.FileUtil;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.support.ExcelTypeEnum;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;
//https://github.com/alibaba/easyexcel/blob/master/quickstart.md
public class Excel_Read {
  public static void main(String[] args) {
    noModelMultipleSheet();
  }
  public static void noModelMultipleSheet() {
    //InputStream inputStream = getInputStream("2007NoModelMultipleSheet.xlsx");
    InputStream inputStream = FileUtil.getInputStream("E:/charge.xlsx");
    try {
      ExcelReader reader = new ExcelReader(inputStream, ExcelTypeEnum.XLSX, null, new AnalysisEventListener<List<String>>() {
        @Override
        public void invoke(List<String> object, AnalysisContext context) {
          System.out.println("当前sheet:" + context.getCurrentSheet().getSheetNo() + " 当前行：" + context.getCurrentRowNum() + " data:" + object);
        }
        @Override
        public void doAfterAllAnalysed(AnalysisContext context) {
        }
      });
      reader.read();
    }
    catch (Exception e) {
      e.printStackTrace();
    }
    finally {
      try {
        inputStream.close();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
}
